package LeetCode.stackvsqueue;

import java.util.Stack;

public class StackToQueue {
    Stack<Integer> stack1 = new Stack<Integer>();
    Stack<Integer> stack2 = new Stack<Integer>();

    public void push(int node){
            while(!stack2.empty()){
                stack1.push(stack2.peek());
                stack2.pop();
            }
            stack1.push(node);
        System.out.println("入队元素是："+stack1.peek());
    }



    public int pop(){
        while(!stack1.empty()){
            stack2.push(stack1.peek());
            stack1.pop();
        }
        System.out.println("出队元素是："+stack2.peek());
        int temp = stack2.peek();
        stack2.pop();
        return temp;
    }


    public static void main(String[] args) {
        StackToQueue so =  new StackToQueue();
        so.push(1);
        so.push(2);
        so.push(3);

        so.pop();
        so.pop();
        so.push(4);
        so.pop();
        so.push(5);
        so.pop();
        so.pop();
    }
}
